package leetcode;

import java.util.Deque;
import java.util.LinkedList;

/**
 * 描述:
 *
 * @author Madison You
 * @created 0:27
 */
public class Mid_151_ReverseWords {
    public static void main(String[] args) {
        System.out.println(new Mid_151_ReverseWords().reverseWords("Alice does not even like bob"));;
    }

    public String reverseWords(String s) {

        Deque<Character> deque1 = new LinkedList<>();
        Deque<Character> deque2 = new LinkedList<>();

        s = s.trim();

        String[] arr = s.split(" ");

        StringBuilder sb = new StringBuilder();

        for (int i = arr.length - 1; i >= 0; i--) {
            if (arr[i] != "") {
                sb.append(arr[i]);
                if (i > 0) {
                    sb.append(" ");
                }
            }
        }

        return sb.toString();

    }
}
